<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p4_居中测试</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .card {
            width: 200px;
            height: 300px;
            background-color: pink;
            border: 5px solid #000;
            margin: 0 auto; /*卡片自己在版心居中*/
            text-align: center;/*文字在卡片里水平居中*/
            line-height: 300px;/*单行文字在卡片里垂直居中*/
        }
        .main {
            background-color: yellow;
        }
        .center {
            width: 1000px;
            background-color: #0aa1ed;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<div class="main">
    <div class="center">
        <div class="card">我是内容</div>
        <div class="card">我是内容</div>
        <div class="card">我是内容</div>
        <div class="card">我是内容</div>
    </div>
</div>
</body>
</html>